<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QLatin1String Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QLatin1String Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QLatin1String class provides a thin wrapper around an
US-ASCII/Latin-1 encoded string literal. <a href="#details">More...</a></p>

<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qlatin1string.html#QLatin1String">__init__</a></b> (<i>self</i>, str&#160;<i>s</i>)</li><li><div class="fn" /><b><a href="qlatin1string.html#QLatin1String-2">__init__</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />str <b><a href="qlatin1string.html#latin1">latin1</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qlatin1string.html#__eq__">__eq__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__eq__-2">__eq__</a></b> (<i>self</i>, QLatin1String&#160;<i>s2</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__eq__-3">__eq__</a></b> (<i>self</i>, QStringRef&#160;<i>s2</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__ge__">__ge__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__ge__-2">__ge__</a></b> (<i>self</i>, QLatin1String&#160;<i>s2</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__gt__">__gt__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__gt__-2">__gt__</a></b> (<i>self</i>, QLatin1String&#160;<i>s2</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__le__">__le__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__le__-2">__le__</a></b> (<i>self</i>, QLatin1String&#160;<i>s2</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__lt__">__lt__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__lt__-2">__lt__</a></b> (<i>self</i>, QLatin1String&#160;<i>s2</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__ne__">__ne__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__ne__-2">__ne__</a></b> (<i>self</i>, QLatin1String&#160;<i>s2</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__ne__-3">__ne__</a></b> (<i>self</i>, QStringRef&#160;<i>s2</i>)</li><li><div class="fn" />str <b><a href="qlatin1string.html#__repr__">__repr__</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>This class can be pickled.</p><p>The QLatin1String class provides a thin wrapper around an
US-ASCII/Latin-1 encoded string literal.</p>
<p>Many of <a href="qstring.html">QString</a>'s member functions
are overloaded to accept <tt>const char *</tt> instead of <a href="qstring.html">QString</a>. This includes the copy constructor, the
assignment operator, the comparison operators, and various other
functions such as <a href="qstring.html#insert">insert()</a>,
<a href="qstring.html#replace">replace()</a>, and <a href="qstring.html#indexOf">indexOf()</a>. These functions are usually
optimized to avoid constructing a <a href="qstring.html">QString</a> object for the <tt>const char *</tt>
data. For example, assuming <tt>str</tt> is a <a href="qstring.html">QString</a>,</p>
<pre class="cpp">
 <span class="keyword">if</span> (str <span class="operator">=</span><span class="operator">=</span> <span class="string">"auto"</span> <span class="operator">|</span><span class="operator">|</span> str <span class="operator">=</span><span class="operator">=</span> <span class="string">"extern"</span>
         <span class="operator">|</span><span class="operator">|</span> str <span class="operator">=</span><span class="operator">=</span> <span class="string">"static"</span> <span class="operator">|</span><span class="operator">|</span> str <span class="operator">=</span><span class="operator">=</span> <span class="string">"register"</span>) {
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 }
</pre>
<p>is much faster than</p>
<pre class="cpp">
 <span class="keyword">if</span> (str <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qstring.html">QString</a></span>(<span class="string">"auto"</span>) <span class="operator">|</span><span class="operator">|</span> str <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qstring.html">QString</a></span>(<span class="string">"extern"</span>)
         <span class="operator">|</span><span class="operator">|</span> str <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qstring.html">QString</a></span>(<span class="string">"static"</span>) <span class="operator">|</span><span class="operator">|</span> str <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qstring.html">QString</a></span>(<span class="string">"register"</span>)) {
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 }
</pre>
<p>because it doesn't construct four temporary <a href="qstring.html">QString</a> objects and make a deep copy of the
character data.</p>
<p>Applications that define <tt>QT_NO_CAST_FROM_ASCII</tt> (as
explained in the <a href="qstring.html">QString</a> documentation)
don't have access to <a href="qstring.html">QString</a>'s <tt>const
char *</tt> API. To provide an efficient way of specifying constant
Latin-1 strings, Qt provides the QLatin1String, which is just a
very thin wrapper around a <tt>const char *</tt>. Using
QLatin1String, the example code above becomes</p>
<pre class="cpp">
 <span class="keyword">if</span> (str <span class="operator">=</span><span class="operator">=</span> QLatin1String(<span class="string">"auto"</span>)
         <span class="operator">|</span><span class="operator">|</span> str <span class="operator">=</span><span class="operator">=</span> QLatin1String(<span class="string">"extern"</span>)
         <span class="operator">|</span><span class="operator">|</span> str <span class="operator">=</span><span class="operator">=</span> QLatin1String(<span class="string">"static"</span>)
         <span class="operator">|</span><span class="operator">|</span> str <span class="operator">=</span><span class="operator">=</span> QLatin1String(<span class="string">"register"</span>) {
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 }
</pre>
<p>This is a bit longer to type, but it provides exactly the same
benefits as the first version of the code, and is faster than
converting the Latin-1 strings using <a href="qstring.html#fromLatin1">QString.fromLatin1</a>().</p>
<p>Thanks to the <a href="qstring.html">QString</a>(const
QLatin1String &amp;) constructor, QLatin1String can be used
everywhere a <a href="qstring.html">QString</a> is expected. For
example:</p>
<pre class="cpp">
 <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>label <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(QLatin1String(<span class="string">"MOD"</span>)<span class="operator">,</span> <span class="keyword">this</span>);
</pre><hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QLatin1String" />QLatin1String.__init__ (<i>self</i>, str&#160;<i>s</i>)</h3><p>Constructs a <a href="qlatin1string.html">QLatin1String</a>
object that stores <i>str</i>. Note that if <i>str</i> is 0, an
empty string is created; this case is handled by <a href="qstring.html">QString</a>.</p>
<p>The string data is <i>not</i> copied. The caller must be able to
guarantee that <i>str</i> will not be deleted or modified as long
as the <a href="qlatin1string.html">QLatin1String</a> object
exists.</p>
<p><b>See also</b> <a href="qlatin1string.html#latin1">latin1</a>().</p>


<h3 class="fn"><a name="QLatin1String-2" />QLatin1String.__init__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><h3 class="fn"><a name="latin1" />str QLatin1String.latin1 (<i>self</i>)</h3><p>Returns the Latin-1 string stored in this object.</p>


<h3 class="fn"><a name="__eq__" />bool QLatin1String.__eq__ (<i>self</i>, QString&#160;<i>s</i>)</h3><h3 class="fn"><a name="__eq__-2" />bool QLatin1String.__eq__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__eq__-3" />bool QLatin1String.__eq__ (<i>self</i>, QStringRef&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__ge__" />bool QLatin1String.__ge__ (<i>self</i>, QString&#160;<i>s</i>)</h3><h3 class="fn"><a name="__ge__-2" />bool QLatin1String.__ge__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__gt__" />bool QLatin1String.__gt__ (<i>self</i>, QString&#160;<i>s</i>)</h3><h3 class="fn"><a name="__gt__-2" />bool QLatin1String.__gt__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__le__" />bool QLatin1String.__le__ (<i>self</i>, QString&#160;<i>s</i>)</h3><h3 class="fn"><a name="__le__-2" />bool QLatin1String.__le__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__lt__" />bool QLatin1String.__lt__ (<i>self</i>, QString&#160;<i>s</i>)</h3><h3 class="fn"><a name="__lt__-2" />bool QLatin1String.__lt__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__ne__" />bool QLatin1String.__ne__ (<i>self</i>, QString&#160;<i>s</i>)</h3><h3 class="fn"><a name="__ne__-2" />bool QLatin1String.__ne__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__ne__-3" />bool QLatin1String.__ne__ (<i>self</i>, QStringRef&#160;<i>s2</i>)</h3><h3 class="fn"><a name="__repr__" />str QLatin1String.__repr__ (<i>self</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>